{-# OPTIONS_GHC -XTemplateHaskell #-}
module Text.XML.WSDL.Wsdl where
import Text.XML.Xmlable
import Text.XML.Xsd
import qualified Text.XML.WSDL.WsdlRename as WsdlRename
import Data.Monoid

data Definitions = Definitions {
        targetNamespace :: String,
        types :: Types,
        message :: [Message],
        portType :: PortType
    } deriving (Eq, Show)

newtype Types = Types { schema :: [Schema] } deriving (Eq, Show)

data Message = Message {
        mName :: String,
        part :: [Part]
    } deriving (Eq, Show)
    
data Part = Part {
        pName :: String,
        element :: String
    } deriving (Eq, Show)
    
data PortType = PortType {
        ptName :: String,
        operation :: [Operation]
    } deriving (Eq, Show)
    
data Operation = Operation {
        oName :: String,
        input :: MessageRef,
        output :: MessageRef
    } deriving (Eq, Show)

newtype MessageRef = MessageRef { mrMessage :: String } deriving (Eq, Show)
    
deriveXmlables False WsdlRename.f [''Definitions, ''Types, ''Message, ''Part, ''PortType, ''Operation, ''MessageRef]

parseWSDL = run (parse :: ParserXml Definitions) (Nothing, mempty)